unit MyInfo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, DBLogic;

type
  TfrmMyInfo = class(TForm)
    CompanyName: TEdit;
    Address: TEdit;
    Phone: TEdit;
    RaschSchet: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    INN: TEdit;
    Label6: TLabel;
    KPP: TEdit;
    Label7: TLabel;
    btnOk: TBitBtn;
    btnCancel: TBitBtn;
    KorrSchet: TEdit;
    procedure btnOkClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    procedure SetControlsState;
  public
    { Public declarations }
  end;

var
  frmMyInfo: TfrmMyInfo;

implementation

{$R *.dfm}

procedure TfrmMyInfo.btnOkClick(Sender: TObject);
var
  Info: TMyInfo;
begin
  Info.CompanyName := CompanyName.Text;
  Info.Address := Address.Text;
  Info.Phone := Phone.Text;
  Info.RaschSchet := RaschSchet.Text;
  Info.KorrSchet := KorrSchet.Text;
  Info.Kpp := Kpp.Text;
  Info.INN := INN.Text;
  WriteMyInfo(ExtractFilepath(ParamStr(0)) + 'MyInfo.txt', Info);
end;

procedure TfrmMyInfo.SetControlsState;
var
  Info: TMyInfo;
begin
  Info := ReadMyInfo(ExtractFilepath(ParamStr(0)) + 'MyInfo.txt');
  CompanyName.Text := Info.CompanyName;
  Address.Text := Info.Address;
  Phone.Text := Info.Phone;
  RaschSchet.Text := Info.RaschSchet;
  KorrSchet.Text := Info.KorrSchet;
  Kpp.Text := Info.Kpp;
  INN.Text := Info.INN;
end;

procedure TfrmMyInfo.FormShow(Sender: TObject);
begin
  if FileExists(ExtractFilepath(ParamStr(0)) + 'MyInfo.txt') then SetControlsState;
end;

end.
